<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0" />
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <title>修改密码</title>
    <link type="image/x-icon" rel="shortcut icon" href="../images/favicon.ico">
    <link rel="stylesheet" href="../res/mui/css/mui.min.css" />
    <link rel="stylesheet" href="../res/fontAwesome/css/font-awesome.min.css" />
    <link rel="stylesheet" href="../css/common.css" />
    <link rel="stylesheet" href="../css/user.css" />
</head>

<body>
    <div class="cz_layout">
        <header class="cz_topBar">
            <a href="javascript:history.back();" class="icon_back fa fa-arrow-left"></a>
            <span class="title">修改密码</span>
        </header>
        <div class="cz_container">
            <div class="form_box">
                <form action="">
                    <div class="mui-input-row">
                        <input name="oldPassword" type="password" placeholder="旧密码" class="mui-input-password">
                        <span class="mui-icon mui-icon-eye"></span>
                    </div>
                    <div class="mui-input-row">
                        <input name="newPassword" type="password" placeholder="新密码" class="mui-input-password">
                        <span class="mui-icon mui-icon-eye"></span>
                    </div>
                    <div class="mui-input-row">
                        <input name="vCode" type="text" placeholder="认证码">
                        <a href="javascript:;" class="btn_getCode mui-btn mui-btn-primary">获取认证码</a>
                    </div>
                </form>
                <a href="javascript:;" class="mui-btn mui-btn-primary btn_login">确认修改</a>
            </div>
        </div>
        <footer class="cz_tabs">
            <a class="tab_home fa fa-home" href="../index.html"><span>首页</span></a>
            <a class="tab_cate fa fa-bars" href="../cate.html"><span>分类</span></a>
            <a class="tab_cart fa fa-shopping-cart" href="../cart.html"><span>购物车</span></a>
            <a class="tab_user fa fa-user" href="../user/index.html"><span>会员中心</span></a>
        </footer>
    </div>
    <script src="../res/mui/js/mui.min.js"></script>
    <script src="../assets/vendors/jquery/jquery.min.js"></script>
    <script src="../assets/vendors/layer/layer.js"></script>
    <script>
        $('.btn_getCode').click(function () {
            $.ajax({
                url: '/api/user/vCodeForUpdatePassword',
                type: 'get',
                success: function (msg) {
                    // console.log(msg.vCode);
                    var vCode = msg.vCode;
                    layer.ready(function () {
                        layer.alert('您的验证码是:' + vCode, {
                                shift: 5,
                                // time: 1000
                            },
                            function (index) {
                                layer.close(index);
                            });
                    });

                }
            });
        });
        $('.btn_login').click(function () {
            var data = $('form').serialize();
            $.ajax({
                url: '/api/user/updatePassword',
                data: data,
                type: 'post',
                success: function (msg) {
                    if (msg.success) {
                        layer.msg('修改成功', {
                                shift: 5,
                                time: 1000
                            },
                            function (index) {
                                // layer.close(index);
                                location.href = '/user/login.html'
                            });
                    }
                }
            });
        });
    </script>
</body>

</html>